home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ASTRONOM / H139.ZIP / RO101.ZIP / RO.DOC < prev    next >
Text File  |  1991-11-04  |  36KB  |  1,255 lines

  1. ..    \"-------------------------------------------------------
  2. ..    \"
  3. ..    \"    ro.doc
  4. ..    \"
  5. ..    \"    documentation for the ro text formatter
  6. ..    \"
  7. ..    \"    NOTE:  This documentation is in "ro" 
  8. ..    \"    format and will not read correctly unless 
  9. ..    \"    it is processed by ro and postprocessed by 
  10. ..    \"    an ro filter.  To read the document on 
  11. ..    \"    a computer with the "more" pager, the 
  12. ..    \"    command line:
  13. ..    \"
  14. ..    \"        ro ro.doc | termnull | more
  15. ..    \" 
  16. ..    \"    should work.
  17. ..    \"
  18. ..    \"-------------------------------------------------------
  19. .so tmac.m
  20. .PH "'ro v1.00''\*(DT'"
  21. .PF "''Page  #''"
  22. .nr Pi 5
  23. .nr Ps 1
  24. .ls 1
  25. .ll 65
  26. .sp 2
  27. .ce
  28. \fBRO.DOC\fR
  29. .sp 1
  30. .ce
  31. \fBDocumentation for the RO Text Formatter\fR
  32. .sp 2
  33. .ce
  34. \fICopyright Information\fR:
  35. .nf
  36.  
  37.     ro, version 1.00:
  38.  
  39.     Portions copyright (c) 1989 by Ted A. Campbell
  40.         Bywater Software
  41.         P. O. Box 4023
  42.         Duke Station
  43.         Durham, NC  27706
  44.  
  45.     Contains portions of ROFF4, Version 1.61
  46.                 (c) 1985 by Konrad Kwok
  47.         20 3rd Street, Section M
  48.         Fariview Park,
  49.         Hong Kong
  50.  
  51.     Contains portions of ROFF4, Version 1.60
  52.                 (c) 1983, 4 by Ernest E. Bergmann
  53.         Physics, Building #16
  54.         Lehigh University
  55.         Bethlehem, Pa. 18015
  56. .fi
  57. .P
  58. \"ro" and its predecessor ROFF4 are based on
  59. the ROFF text processor described in Brian W. Kernigan
  60. and P. J. Plauger's now-classic text \fISoftware Tools\fR 
  61. (Reading, MA: Addison-Wesley, 1976).  
  62. .P
  63. Permission is hereby granted for all commercial and
  64. non-commercial reproduction and distribution of this
  65. material provided this notice is included.
  66. .ne 4
  67. .sp 2
  68. .ce
  69. \fIGeneral Description\fR
  70. .P
  71. \"ro" is a text formatter.  It is based on the 
  72. CP/M ROFF4 formatter, 
  73. which was an expanded version of ROFF, itself based on the
  74. formatter in Kernigan and Plauger's \fISoftware Tools\fR.  
  75. It is written in the C programming language, and has 
  76. been successfully compiled on both Unix and DOS 
  77. computers.  
  78. .P
  79. \"ro" is designed to be downwardly-compatible 
  80. with the Unix-based "nroff" text formatter, 
  81. and efforts have been made to make this 
  82. version of ro as much like nroff as possible, 
  83. although many nroff features (like 
  84. withholding traps) are not yet implemented 
  85. in ro.  
  86. \"ro" adds some features to nroff, such as 
  87. debug and verbose modes (using the "-x" and "-v" 
  88. flags, respectively), and a number of predefined 
  89. commands which are usually implemented as macros 
  90. in nroff (e.g., .HE, which sets a three-part 
  91. page header).  
  92. .P
  93. Included with this implementation of ro 
  94. is a package of macros named "tmac.m".  
  95. This implements some of the macros 
  96. found in the popular nroff-based 
  97. \"-mm" macro package.  
  98. .ne 8
  99. .sp 2
  100. .ce 
  101. \fIUsing ro\fR
  102. .sp 1
  103. \fIInvoking the Program\fR:
  104. .P
  105. \"ro" is command-line based, 
  106. and by default takes its input 
  107. from "standard input."  
  108. All output is sent to "standard output."  
  109. The command 
  110. .sp
  111. .ti 5
  112. \ro 
  113. .sp
  114. by itself would simply read input from 
  115. the keyboard and output to the screen.  
  116. Utilizing the command-line "<" and ">" 
  117. operators in Unix and DOS, you can redirect 
  118. both the standard input and the standard output.  
  119. Thus the command 
  120. .sp 
  121. .ti 5
  122. \ro <infile >outfile
  123. .sp
  124. would take its input from "infile" and send output 
  125. to "outfile."  
  126. .P
  127. It is possible to send output 
  128. directly to the printer utilizing 
  129. output redirection.  In Unix, the command 
  130. .sp
  131. .ti 5
  132. \ro <infile >/dev/lp
  133. .sp
  134. would take its input from "infile" and 
  135. send the output to "/dev/lp", 
  136. which is usually implemented as the line printer.  
  137. Similarly, in DOS, the command 
  138. .sp
  139. .ti 5
  140. \ro <infile >prn
  141. .sp
  142. would send output to the "PRN" device, 
  143. which is normally attached to the printer.  
  144. \fBHowever\fR, it is usually undesirable 
  145. to send output directly to a printer 
  146. (or the screen, for that matter), 
  147. since ro output will likely 
  148. include unprocessed printer escape codes.  
  149. For this reason, it is deirable to use an 
  150. output "post-processor" (see below 
  151. under \fIUsing a Post-Processor\fR).  
  152. .P
  153. \"ro" can also take its input from files named 
  154. directly on the command line (without the 
  155. \"<" operator).  The command 
  156. .sp
  157. .ti 5
  158. \ro infile
  159. .sp
  160. would read input directly from "filename", 
  161. and the command 
  162. .sp 
  163. .ti 5
  164. \ro file1 file2 file3
  165. .sp
  166. would read input from files "file1", 
  167. \"file2", and "file3" successively.  
  168. Note that input must be from named files 
  169. (and not from standard input) 
  170. if you wish to utilize the "-s" flag 
  171. option (described below).  
  172. .ne 4
  173. .sp 2
  174. \fICommand-Line Flags\fR
  175. .P
  176. \"ro" utilizes a number of command-line flags 
  177. to control the program.  
  178. All flags are processed before text input is received.  
  179. .P
  180. The \fB-s\fR flag, causes the formatter to stop (pause)
  181. at the start of each page of output; a tone at the
  182. console is sounded and the program
  183. waits until the RETURN key is pressed.  It
  184. is essential for printers that are fed single sheets
  185. at a time!
  186. \fBPlease note\fR that to utilize this feature, 
  187. you must name files directly on the command 
  188. line.  (This is because the key-press to resume 
  189. printing must itself come from standard input.)  
  190. .P
  191. The \fB-o[page or range]\fR flag 
  192. is used to selectively generate output of ONLY certain
  193. pages.  It is useful to retype pages that got "eaten"
  194. by the printer (Henry Harpending's aptly put language).
  195. To retype only page 23, say, make the option: -o23
  196. To retype pages 23 through 29 use: -o23-29
  197. To retype pages 23 to the end use: -23-
  198. These options changes the values of the internal
  199. variables, FIRSTPAGE and LASTPAGE which originally
  200. have the values of 1 and 30000, respectively.  
  201. .P
  202. The comamnd-line flag \fB-f\fR will introduce a formfeed (0CH)
  203. into the output stream at the bottom of every page.  
  204. This is usefull, e.g., if you want to output in compressed 
  205. pitch where the end of the printed page might not 
  206. corrrespond to the end of the physical page.  
  207. .P
  208. The flag \fB-v\fR turns on "verbose" mode.  
  209. In this mode, some chit-chatty messages are 
  210. printed to "standard error" (almost always 
  211. the console), including some rather important 
  212. error messages.  Normally, only fatal error 
  213. messages are printed when verbose mode is not on 
  214. (because ro is expected 
  215. to do much of its work in the background).  
  216. .P
  217. The option \fB-x\fR turns on the "debug" flag so as to
  218. print out lots of diagnostics to the STDERR [console].
  219. Probably only useful for those who are trying to
  220. trace the operation of the formatter for elusive
  221. \"bugs". 
  222. Specifying the "-x" flag will also turn on 
  223. the "verbose" mode (but not \fIvice versa\fR).  
  224. .ne 4
  225. .sp 2
  226. \fIDefault Values\fR
  227. .P
  228. Using ro, you can make nice printouts of a file,
  229. with as little or as much help from the program as you want,
  230. depending on the commands.  There are default values for all
  231. parameters, so if you don't put any commands in at all, your
  232. file will come out with filled, right-justified lines.  The
  233. default line-length is 65 characters; the default page-
  234. length is 66 lines per page.  "Filled lines" means that as
  235. many input words as possible are packed onto a line before
  236. it is printed; "non-filled" lines go through the formatter
  237. w/o rearrangement.  "Adjusted" or "right-justified" simply means that
  238. spaces are added between words to make all the right margins
  239. line up nicely.  To change a parameter, use the appropriate
  240. commands below. All commands have the form of a period
  241. followed by two letters. A command line should have nothing
  242. on it but the command and its arguments (if any); any text
  243. would be lost. 
  244. .ne 4
  245. .sp 2
  246. \fIUsing a Postprocessor\fR
  247. .P
  248. \"ro" does not handle printer-specific control codes itself; 
  249. instead, it sends out simple (but consistent) escape 
  250. sequences which have to be "post-processed" by another program 
  251. to fit a particular terminal or printer.  
  252. Three example post-processors are provided 
  253. with ro:  
  254. .sp
  255. .nf
  256.     termnull     strips out all printer codes
  257.     termansi    prepares sequences for an ANSI-
  258.             compatible terminal
  259.     termnx10    prepares sequences for the Star 
  260.             NX10 printer
  261. .fi
  262. .sp
  263. All of these postprocessors take their input 
  264. from standard input, and send their output 
  265. to standard output.  
  266. .P
  267. You can use the "|" ("pipe") operator 
  268. to send the output from ro directly to 
  269. a postprocessor, and you can use "|" again 
  270. to send the post-processor's output to 
  271. a print spooler, pager, or other program.  
  272. Here are some useful examples:  The command
  273. .sp
  274. .ti +5
  275. \ro filename | termnull | more
  276. .sp
  277. involes ro with input from "filename", 
  278. pipes its output to termnull, where all 
  279. printer sequences are stripped away, 
  280. and then sends its output to the "more"
  281. pager.  Utilizing this sequence, one 
  282. could preview "filename" on any terminal, 
  283. although no printer-specific sequences would 
  284. be shown.  For ANSI-compatible terminals 
  285. (including DOS computers which have ANSI.SYS 
  286. installed), the sequence
  287. .sp
  288. .ti +5
  289. \ro filename | termansi | more
  290. .sp
  291. would do the same as the previous command, 
  292. except that boldface would appear 
  293. in bold, and italics would appear underlined 
  294. in the output.  
  295. The Unix sequence
  296. .sp 
  297. .ti +5
  298. \ro filename | termnx10 | lp
  299. .sp
  300. would take input from "filename", 
  301. set up sequences for the Star NX10 
  302. printer, and send the output 
  303. to the "lp" print spooler.  
  304. Similarly, under DOS,
  305. .sp 
  306. .ti +5
  307. \ro filename | termnull >prn
  308. .sp 
  309. would take input from "filename",
  310. strip out all printer codes, and 
  311. send the output to the PRN device 
  312. (normally attached to the printer).  
  313. .P
  314. The escape codes sent out by ro are simple, and are 
  315. listed at the end of this document.  
  316. With these and the source code to termnx10 (included), 
  317. it should 
  318. be relatively easy to write a post-processor 
  319. for almost any terminal or device.  
  320. .ne 8
  321. .sp 2
  322. .ce
  323. \fIInput to ro\fR
  324. .sp 1
  325. \fIInput Text\fR
  326. .P
  327. \"ro" generally reads input until it can fill out 
  328. a complete line of text (specfied by the "line length" 
  329. variable, set by the command .ll).  
  330. By default, it then "adjusts" or justifies these 
  331. input line when putting them out.  
  332. Both the "filling" and the "adjustment" of lines 
  333. can be toggled on and off (see the commands 
  334. described below, .fi, .nf, .ad, .na).  
  335. .P
  336. Extra space will separate text sentences.  The sentence
  337. is recognized by a trailing ':',';','!','?', or a '.'.  For
  338. the '.' there is the additional requirement that either two
  339. or more spaces must spaces must follow it, or that it is at the
  340. end of the source line.
  341. .ne 4
  342. .sp 2
  343. \fIInput Commands and Their Arguments\fR
  344. .P
  345. \"ro" is controlled internally by commands 
  346. that are identified by a period ('.') in the 
  347. first place on a line.  
  348. Be carefull:  if you inadvertently place 
  349. a period in the first place in a line, 
  350. \"ro" will try to interpret it 
  351. as a command.  
  352. \"ro" commands are either one or two letters 
  353. in length, and are all case-sensitive, 
  354. i.e., the command 
  355. .sp 
  356. .ti +5
  357.  .In
  358. .sp
  359. is different from the command
  360. .sp 
  361. .ti +5
  362.  .in
  363. .sp
  364. and so on.  
  365. By convention, built-in commands are lower-case, 
  366. and macros (see below) are upper-case; 
  367. however, this is not a rule, and we have elected 
  368. to place all non-nroff compatible commands 
  369. in upper case, since this is how they appear 
  370. in nroff implementations.  
  371. .P
  372. A command argument can be either ABSOLUTE or RELATIVE : 
  373. .br
  374. .nf
  375. .sp
  376.  .in     5       sets the indent value to 5 spaces
  377.  .in     +5      sets the indent value to the CURRENT value+5
  378.  .ls     -1      sets the line spacing to the current value-1
  379. .fi
  380. .P
  381. Also,  all commands have a minimum and maximum value
  382. that will weed out any odd command settings (like setting
  383. the line spacing to zero, for example. It won't let you do
  384. that, but it could be changed (by recompiling 
  385. the program).
  386. .P
  387. Some commands cause a "break", which is noted in the
  388. table below.  Before such a command goes into effect, the
  389. current line of text is put out, whether it is completely
  390. filled or not. (this is what happens at the end of a
  391. paragraph, for example.)  A line beginning with spaces or a
  392. tab will cause a break, and will be indented by that many
  393. spaces (or tabs) regardless of the indent value at that time
  394. (this is a "temporary indent", which can also be set
  395. explicitly).  An all blank line also causes a break.  If you
  396. find that some lines that are indented strangely, and it's
  397. not obvious WHY, look at which commands are causing a break,
  398. and which aren't. For instance:
  399. .sp
  400. .nf
  401.  .fi
  402.  .ti 0
  403.  this is a line of text
  404.  .in 8
  405.                                         <- blank line
  406.  more text for the machine to play with
  407. .fi
  408. .P
  409. At first glance it seems obvious that the line "this is a
  410. line of text" will be indented zero spaces, but it won't -
  411. it will be indented 8. The indent command does NOT cause a
  412. break (although the .ti does) so it will not cause the line
  413. to be put out before setting the indent value to 8.  Then,
  414. when the blank line is encountered, it will cause a break -
  415. and "this is a line of text" will be indented incorrectly.
  416. The above example will give the following lines.
  417. .sp
  418. .fi
  419. .ti +5
  420. this is a line of text
  421. .sp
  422. .ti +5
  423. more text for the machine to play with
  424. .br
  425. .in
  426. .P
  427. It is worthwhile considering placing a ".br", the
  428. break command, before each use of ".in".  
  429. .P
  430. Certain system variables are "stacked" to enable
  431. reversion to earlier environments instead of "hardcoded"
  432. defaults.  For example:
  433. .sp
  434. .nf
  435.  .ls 1
  436.   .
  437.   .
  438.  .ls
  439. .sp
  440. .fi
  441. The first command will produce single line spacing (which is
  442. the default, but which may have been set otherwise at the
  443. beginning of the manuscript).  The second command causes
  444. resumption of the original line spacing (either the default
  445. or whatever had been chosen previously).  Stacked variables
  446. include: linespacing, indent column, line length,
  447. translation flag character, page length, top and bottom
  448. margin sizes, unexpandable space character, output width,
  449. and tabsize.
  450. .nf
  451. .ne 8
  452. .sp 4
  453. *********************** Table of Commands *********************
  454.  
  455.  Command       Break?    Default stacked Function
  456.  -------       ------    ------- ------- ---------
  457.  
  458. A. nroff-compatible commands (* denotes compatibility limitation)
  459.    --------------------------------------------------------------
  460.  
  461.  .. string       no                      string is "mere" comment
  462.                                          (or end of macro definition)
  463.  
  464.  .ad             no      initially on    turn right justification 
  465.                                          on (use .na to turn off); 
  466.                                          only applicable if 
  467.                                          "filling" is also on.
  468.  
  469.  .bp n           yes     n =  +1         begin page numbered n
  470.  
  471.  .br             yes                     cause a break (this
  472.                                          line is not justified)
  473.  
  474.  .ce n           yes     n = 1           center next n lines
  475.  
  476.  .di name (*)    no      junk.$$$        diversion file
  477.                                          (see "PREPROCESSOR")
  478.  
  479.  .de name        no                      define (multiline)
  480.                                          macro ("PREPROCESSOR")
  481.  
  482.  .ds name string no      null string     define string replace-
  483.                                           ment ("PREPROCESSOR")
  484.  
  485.  .em                                     end macro
  486.                                          (see "PREPROCESSOR")
  487.  
  488.  .ex             no                      immediate abort back to
  489.                                          system
  490.  
  491.  .fi             yes                     start filling lines
  492.  
  493.  .ig string      no                      "ignore" string (see ..)
  494.  
  495.  .in n           no      n = 10  Yes     set indent value to n
  496.  
  497.  .ll n           no      n = 65  Yes     set line length (right 
  498.                                          margin)
  499.  
  500.  .ls n           no      n = 1   Yes     set line spacing to n
  501.  
  502.  .na             no      initially on    turn right justification 
  503.                                          off (use .ad to turn on)
  504.  
  505.  .ne n           no/yes  n = 2           "need" n lines; if have
  506.                                          them no action; else
  507.                                          begins new page
  508.  
  509.  .nf             yes                     stop filling lines
  510.  
  511.  .nr name n      no      n=0     No      create or modify 
  512.                                          register variable
  513.                                          (see "PREPROCESSOR")
  514.  
  515.  .pl n           no      n = 66  Yes     sets page length to n
  516.  
  517.  .pm                                     print macros defined 
  518.                                          (for debugging)
  519.  
  520.  .po         no      0       No      sets page offset (spaces 
  521.                                          at left margin of every 
  522.                                          line.  
  523.  
  524.  .so filename    no      ignored Yes     reads named file into
  525.                                          input stream; cannot be
  526.                                          invoked from keyboard
  527.                                          input.
  528.  
  529.  .sp n           yes     n = 1           space down n lines
  530.  
  531.  .ta n           no      n = 8   Yes     sets value of tab space
  532.  
  533.  .tc c           no      ~       Yes     set translation flag
  534.                                          character, see .tr
  535.  
  536.  .ti n           yes     n = 0           set temp. indent of n
  537.  
  538.  .tm string                              send message to terminal 
  539.                                          (console); like a comment
  540.                                          but displayed to
  541.                                          operator during run.
  542.  
  543.  
  544. .ne 8
  545. B. non-nroff-compatible commands (must be upper-case)
  546.    --------------------------------------------------
  547.  
  548.  .BJ             yes                     break with right
  549.                                          justification (current
  550.                                          line only)
  551.  
  552.  .DB n           no      n = 0(NO)       set debug flag 1 for
  553.                                          diagnostics
  554.  
  555.  .EF /../../../  no      blanks          even footer titling
  556.  
  557.  .EH /../../../  no      blanks          even header titling
  558.  
  559.  .FF n           no      n = 1(yes)      initially, formfeeds
  560.                                          are "off". Can turn
  561.                                          them on.  Each page
  562.                                          then terminated with
  563.                                          one formfeed.
  564.  
  565.  .FO /../../../  no      empty           sets both even and odd
  566.                                          page footers
  567.  
  568.  .HE /../../../  no      empty           sets both even and odd
  569.                                          page headers
  570.  
  571.  .M1             no      n = 2   Yes     set topmost margin to n
  572.  
  573.  .M2             no      n = 2   Yes     set 2nd top margin to n
  574.                                          lines
  575.  
  576.  .M3             no      n = 2   Yes     1st bottom margin to n
  577.                                          lines
  578.  
  579.  .M4             no      n = 2   Yes     bottom-most margin to n
  580.                                          lines
  581.  
  582.  .OF /../../../  no      empty           odd page footer title
  583.  
  584.  .OH /../../../  no      empty           odd page header title
  585.  
  586.  .SC c           no      blank   Yes     space character; the
  587.                                          visible character
  588.                                          that will be trans-
  589.                                          literated to unexpanded
  590.                                          blank.
  591.  
  592.  .SR                                     show registers defined
  593.  
  594.  .SS                                     show strings defined
  595.  
  596.  .ST n           no      n = 1   (yes)   stop (pause) at each page
  597.                                          start; initially off;
  598.                                          may also be enabled by
  599.                                          the -s option.
  600.  
  601. .ne 27
  602. .sp 2
  603. Here's what the page parameters look like:
  604.  
  605.         |<--------output width ------------------------>|
  606.  
  607. |- po --| ( "po = page offset")
  608. _       _________________________________________________
  609. |       |       top margin(m1) - (includes header)      |
  610. |       |-----------------------------------------------|
  611. |       |               top margin 2                    |
  612. |       |-----------------------------------------------|
  613. P       |       :                               :       |
  614. A       |       :<-indent                       :       |
  615. G       |       :                               :       |
  616. E       |       :lots and lots of silly text and:       |
  617. L       |       :other garbage. Get the picture?:       |
  618. E       |          :This is a temp.  indentation:       |
  619. N       |       :                               :       |
  620. G       |       :               right margin -> :       |
  621. T       |       :                               :       |
  622. H       |       :                               :       |
  623. |       |-----------------------------------------------|
  624. |       |               margin 3                        |
  625. |       |-----------------------------------------------|
  626. |       |  margin 4 - (includes footer,perhaps ff)      |
  627. -       -------------------------------------------------
  628.  
  629. .fi
  630. Minimum acceptable values for M1, M2, M3, and M4: if M1 is set
  631. to zero, no header will be shown (even if one was declared).
  632. Similarly, if M4 is set to zero, no footer will be displayed.
  633. .P
  634. To change the default for any parameter, you must alter ro.h
  635. and recompile.
  636. .ne 4
  637. .sp 2
  638. \fISome Notes on Input Commands\fR
  639. .P
  640. \fB".ce"\fR.  
  641. If you want to center lots of lines, but don't
  642. want to count them, do something like this:
  643. .sp
  644. .nf
  645.  .ce     1000
  646.  lots and
  647.  lots of words to
  648.  be centered
  649.  .ce 0
  650. .sp
  651. will give the lines:
  652. .ce 1000
  653. lots and
  654. lots of words to
  655. be centered
  656. .ce 0
  657. .fi
  658. .sp
  659. .P
  660. \fB".ti"\fR.  
  661. A new paragraph may be caused by using the temporary indent
  662. command, like
  663. .sp
  664. .nf
  665.  .ti +5
  666. .fi
  667. .sp   
  668. or by simply beginning the paragraph with a tab.
  669. .ne 4
  670. .sp 2
  671. \fIHeader and Footer Commands\fR
  672. .P
  673. A page number can be incorporated into any header or
  674. footer by putting a "#" in the title where you want the number
  675. to go:
  676. .nf
  677.  .he     //This is a witty header title for page #//
  678. .fi
  679. Each time this is printed at the top of a page, the current
  680. page number will be substituted for the "#".
  681. Each footer and header are ".in 0", even if text is
  682. indented.
  683. .P
  684. Headers and footers are in three parts.  These parts are left
  685. justified, centered, and right justifed.  Any of these three
  686. parts may be left out.  One may pick the
  687. headers and footers separately for even and odd pages.  For
  688. example, one could place even and odd page numbers at the
  689. bottom outside of each page by:
  690. .sp
  691. .nf
  692.  .EF /Page #///
  693.  .OF ///Page #/
  694. .fi
  695. .P
  696. Any printable character, here the '/', can be used to
  697. delimit the three strings that make up the titles, so long
  698. as it is not the backslash character ('\\') and is
  699. not present in any of the three strings.
  700. .P
  701. The program can be made to wait for the operator to
  702. load single sheets of paper by the -s option and/or by the
  703. command: .ST
  704. .P
  705. If you want to send the output to a file, and don't want the
  706. page breaks in there set margins 1-4 to zero.
  707. .ne 4
  708. .sp 2
  709. \fIPrinter Control Input\fR
  710. .P
  711. At present, ro recognizes only five sequences
  712. for printer control.  These, with their input 
  713. symbols, are:
  714. .sp 
  715. .nf
  716.     \\fR    Switch to Roman Font
  717.  
  718.      \\fI    Switch to \fIItalic\fR Font
  719.  
  720.     \\fB    Switch to \fBBold\fR Font
  721.  
  722.     \\u    Up \uone-half\d line
  723.  
  724.     \\d    Down \done-half\u line
  725. .fi
  726. .sp
  727. The "Roman" (or perhaps "Regular") font turns off 
  728. both Italic and Bold fonts.  The \\u and \\d 
  729. commands are useful in depicting superscripts 
  730. and subscripts.  
  731. .P
  732. Fonts can also be switched using the ".ft" 
  733. input command.  For example, the command 
  734. .sp
  735. .ti +5
  736.  .ft R
  737. .sp
  738. would set the Roman font for subsequent input.  
  739. .ne 8
  740. .sp 2
  741. .ce
  742. \fIThe Preprocessor\fR
  743. .sp 1
  744. \fIString Definitions\fR
  745. .P
  746. In the following we describe the advanced macro
  747. preprocessing features of this formatter which provide users
  748. with labor saving tools but which are probably not necessary
  749. at first.  The beginning user may be able to achieve most
  750. goals without the "preprocessing", but by using an editor
  751. more then otherwise.  The more advanced user will begin to
  752. appreciate these features more.
  753. .P
  754. For example, in:
  755. .sp
  756. Today, \\*(da, is special.
  757. .sp
  758. the block, "\\*(da", would be replaced as this sentence is
  759. being input.  If a prior string definition of the form:
  760.  
  761.  .ds da "January 1, 1983"
  762. .ds da "January 1, 1983"
  763.  
  764. had been processed previously then the example, after text
  765. substitution, would become:
  766. .sp
  767. .ti +5
  768. Today, \*(da, is special.
  769. .P
  770. The string definition command, .ds, expects two arguments:  
  771. a name of one or two characters (case is significant), 
  772. and then either a single word (no whitespace) or 
  773. a string delimited by double quotation marks ("...").   
  774. A single-letter string name is expanded on output 
  775. when the letter is preceded by "\\*".  
  776. For example, one could define a string N using 
  777. .sp 
  778. .ti +5
  779.  .ds N "Alfred E. Newman"
  780. .sp
  781. and then whenever the sequence \\*N appears 
  782. in the input text, the string "\*N" would 
  783. be output.  
  784. A two-letter string name is expanded on output 
  785. when it is preceded by "\\*(".  
  786. Thus, in the example above, the string "da" 
  787. is defined, and output with "\\*(da", 
  788. yielding "\*(da".  Did it work?  
  789. .ne 4
  790. .sp 2
  791. \fINumber Registers\fR
  792. .P
  793. Similar to string definitions are number register
  794. variables, which are created and modified with the \fB.nr\fR
  795. command.  Variables are useful for enumeration such as
  796. equation numbering:
  797. .sp
  798. .ti +5
  799.  .nr eq 1
  800. .nr eq 1
  801. .sp
  802. would create a register named "eq" with the current value
  803. of 1.  The the text might use it with, say:
  804. .sp
  805. .ti +5
  806. x = y+1          \\n(eq
  807. .sp
  808. which would be converted on input into:
  809. .sp
  810. .ti +5
  811. x = y+1          \n(eq
  812. .sp
  813. A subsequent instruction:
  814. .sp
  815. .ti +5
  816.  .nr eq +1
  817. .nr eq +1
  818. .sp
  819. would take the current value of "eq" and increase it by 1
  820. (so that it would now be 2 in our example:
  821. .sp
  822. .ti +5
  823. a = b+c          \\n(eq
  824. .sp
  825. would become:
  826. .sp
  827. .ti +5
  828. a = b+c          \n(eq
  829. .P
  830. Number Register values are expanded on output 
  831. in a manner similar to string variables, except 
  832. that "n" (must be lower-case) is used in place 
  833. of "*".  Thus the register variable "P" would 
  834. be expanded by "\\nP", and the register "Pi" 
  835. would be expanded by "\\n(Pi", just as "eq" 
  836. is expanded by "\\n(eq" above.   
  837. .P
  838. There is a special, reserved insertion, \#\, which
  839. will provide the current page number.  It should prove
  840. useful in setting up tables of contents (see "diversions",
  841. below).  
  842. .P
  843. Since we have defined a special register name, '#',
  844. we should comment on what happens if you create a register
  845. instruction with that name, such as:
  846. .sp
  847. .ti +5
  848.  .nr # +1
  849. .sp
  850. You will be changing the value of the page number of the
  851. FOLLOWING pages.  This is useful for leaving gaps in the 
  852. pagination for later inclusion of full page illustrations.
  853. This feature is demonstrated (tested) in the file, MARGINS.
  854. I wish to thank Henry Harpending for suggesting this.
  855. .P
  856. \"ro" includes some predefined number registers 
  857. that are available to users.  These are:  
  858. .sp
  859. .nf
  860.     dy    current day of the month
  861.     mo    current month as integer (1-12)
  862.     yr    current year -1900
  863. .fi
  864. .sp
  865. Thus, a user could say, 
  866. \"Today's date is \\n(dy/\\n(mo/\\n(yr", 
  867. and this would be ouput as 
  868. \"Today's date is \n(dy/\n(mo/\n(yr".  
  869. .ne 4
  870. .sp 2
  871. \fIUsing Backslashes\fR
  872. .P
  873. The backslash character has other properties.  
  874. It can be placed into the input by repeating
  875. it, namely, "\\\\" becomes "\\".  (useful for delaying
  876. substitutions).  For example, defining:
  877. .sp
  878. .ti +5
  879.  .ds EN "\\n(eq"
  880. .ds EN "\\n(eq"
  881. .sp
  882. will identify "EN" with "\\n(eq" and so our equation
  883. example above could have been:
  884. .sp
  885. .ti +5
  886. a = b + c          \*(EN
  887. .sp
  888. Delaying the evaluation of "eq" until EN is invoked
  889. (instead of when it was defined) means that the proper
  890. numbering of equations will occur instead of wrongly
  891. supplying the value of "eq" from the time that EN was
  892. first created.
  893. Utilizing this technique, 
  894. the "tmac.m" package defines a macro for the 
  895. current date, which is:  
  896. .sp
  897. .ti +5
  898.  .ds DT "19\\\\n(yr/\\\\n(mo/\\\\n(dy"
  899. .ds DT "19\\n(yr/\\n(mo/\\n(dy"
  900. .sp
  901. This would be expanded using "\\*(DT", 
  902. which would produce "\*(DT" (did it work?).  
  903. .ne 4
  904. .sp 2
  905. \fIMacro Definitions\fR
  906. .P
  907. "Macro" definitions are used when we wish to
  908. identify several lines with an insertion.  Such definitions
  909. are created with the .de ["define macro"] and completed with
  910. the .. ["end macro"] commands.  For example, we might wish
  911. to use the following sequence over and over again at the
  912. start of paragraphs:
  913. .sp
  914. .nf
  915.  .sp 1
  916.  .ne 2
  917.  .ti +5
  918. .fi
  919. .P
  920. to separate the paragraphs by blank lines, keep them from
  921. starting excessively close to the bottom of the page, and
  922. indenting them 5 spaces to the right of the current left
  923. margin.  
  924. .nf
  925. .sp
  926.  .de P
  927.  .sp 1
  928.  .ne 2
  929.  .ti +5
  930.  ..
  931. .fi
  932. .P
  933. Subsequently, whenever we wished to start a paragraph we
  934. would create a command line:
  935. .sp
  936. .ti +5
  937.  .P
  938. .sp
  939. instead of more tediously creating every time the three
  940. commands we mentioned above.
  941. .P
  942. The names of all macros, strings, and number
  943. registers are "case sensitive".  That is to say that
  944. capitalization and/or lower case are distinguished and, say,
  945. .sp 
  946. .ti +5
  947.  .p
  948. .sp
  949. Would not be recognized as the same as the sample macro we
  950. just defined.  
  951. The macro is read until a line beginning with ".em" (end macro) 
  952. or simply ".." is reached.  
  953. .P
  954. A macro command may contain parameters(s). For example
  955. .sp
  956. .nf
  957.  .de He
  958.  $0
  959.  ..
  960. .de He
  961. $0
  962. ..
  963. .fi
  964. .sp
  965. defines a simple macro for printing a heading.  
  966. When the line ".He Heading" 
  967. appears at the beginning of a line, the word "Heading" 
  968. will be printed, i.e.:
  969. .sp
  970. .He Heading
  971. .P
  972. The maximum number of parameters for a macro is 10 ($0-$9). 
  973. The parameter(s) must be on the same line of the macro call. 
  974. The parameters are separate by a non-alphanumeric character 
  975. except '+' and '-' which
  976. appear as the first character of the parameter line. If the 
  977. first character is a alphanumeric character, then white space 
  978. will be assumed as the delimiter. An example can be found 
  979. above. If the require parameter(s) is/are not defined by the 
  980. macro call, then the parameter(s) will be treated as null 
  981. string.
  982. .ne 4
  983. .sp 2
  984. \fIDiversions\fR
  985. .P
  986. There is another object formed and used somewhat
  987. like a macro;  it is called a "diversion (file)" and is
  988. useful for making lists such as references [notes] and
  989. tables of contents.  A diversion is created or continued
  990. with the command: \fB.di\fR [diversion].  
  991. It is ended with the same command 
  992. (the command to begin the diversion should 
  993. have a one- or two-letter name argument; 
  994. the command to end it should have no argument.  
  995. A diversion can grow to be quite large and is, in "ro", a
  996. disk file.  To "regurgitate" the diversion file, its 
  997. name must be entered as a command at the beginning of a line.  
  998. .P
  999. For example, the "tmac.m" macros define .FS 
  1000. (start footnote -- actually and endnote) 
  1001. as including the command ".di no".  
  1002. Internally, at this point, ro creates a disk file 
  1003. named "no_ro.div" and begins placing all input 
  1004. in this file.  
  1005. The macro ".FE" (footnote end) includes the command ".di".  
  1006. At this point the diversion to "no_ro.div" is 
  1007. ceased, and input is again read as normal.  
  1008. For each .FS - .FE pair, this sequence is 
  1009. repeated, so that the diversion file collects 
  1010. all the footnotes.  
  1011. Finally, the macro ".PN" (printout notes) 
  1012. includes the command ".no" which ro 
  1013. recognizes as the signal to send out all 
  1014. the material collected in the diversion file.  
  1015. \".PN" is placed last in the text file, so that 
  1016. the notes follow after the text.  
  1017. .ne 8
  1018. .sp 2
  1019. .ce
  1020. \fIUsing the tmac.m Macro Package\fR
  1021. .P
  1022. The file "tmac.m" included with this distribution 
  1023. defines some macros for use in processing documents.  
  1024. These are roughly equivalent to the nroff "-mm" macros
  1025. of similar names.  
  1026. You can very easily customize this package and add 
  1027. to it for your own uses.  
  1028. .P
  1029. \fIParagraph Control\fR.  
  1030. Using the tmac.m macros, the command 
  1031. .sp 
  1032. .ti +5
  1033.  .P
  1034. .sp
  1035. is used to begin a paragraph.  
  1036. There are two number registers associated with 
  1037. this command:  
  1038. .sp
  1039. .ti +5
  1040. .nf
  1041.      Ps        paragraph spacing, and 
  1042. .ti +5
  1043.      Pi        paragraph indent.  
  1044. .fi
  1045. .sp
  1046. Each time .P is called, "Ps" lines are skipped, and a 
  1047. temporary indent of "Pi" characters is set.  
  1048. .P
  1049. \fIThe Date String\fR.  
  1050. With the tmac.m package, the current date 
  1051. is stored in the string "DT" and can 
  1052. therefore be output at any point with \\*(DT.  
  1053. This yields "\*(DT", and is used in the page 
  1054. header for this documentation (see at the top of this page).  
  1055. .P
  1056. \fIEndnote Control\fR.  
  1057. Although ro does not currently support footnotes 
  1058. (because it does not implement a withholding trap), 
  1059. there are three macros and a string definition to 
  1060. support endnotes.  These are:  
  1061. .sp
  1062. .nf
  1063.     \\*F    prints current note number, superscript
  1064.     .FS    starts text of note
  1065.     .FE    ends text of note
  1066.     .PN    prints out all notes collected
  1067. .fi
  1068. .sp
  1069. The command ".FS" begins diversion to a separate file, 
  1070. so you must be careful to end the text of the note with 
  1071. the ".FE" command.  Also, be sure to include the ".PN" 
  1072. command at the point where you want the notes to be 
  1073. printed out (normally at the very end of the file).
  1074. .P
  1075. \fIFont Control\fR.  
  1076. The tmac.m package contains three macros 
  1077. consistent with the "-mm" package for switching 
  1078. fonts.  These are:
  1079. .sp
  1080. .nf
  1081.     .R    switch to Roman (regular) font
  1082.     .I    switch to Italic font
  1083.     .B    switch to Bold font
  1084. .fi
  1085. .P
  1086. \fIPage Header and Footer Control\fR.  
  1087. The tmac.m package defines two macros 
  1088. consistent with "-mm" which reset page 
  1089. headers and footers:  
  1090. .sp
  1091. .nf
  1092.     .PH    page header
  1093.     .PF    page footer
  1094. .fi
  1095. .sp
  1096. Note that the arguments to these must be three-part titles 
  1097. enclosed in double quotation marks, e.g., 
  1098. .sp
  1099. .fi
  1100.     .PH "'left'center'right'"
  1101. .sp
  1102. This differs from the usage of the built-in .HE 
  1103. and .FO commands.  
  1104. .P
  1105. \fIText and Block Macros\fR.  
  1106. Finally, the tmac.m package defines macros 
  1107. not found in "-mm" that I have found helpful 
  1108. in writing papers.  These are:  
  1109. .sp
  1110. .nf
  1111.     .TA    begin double-spaced text segment
  1112.     .TZ    end double-spaced text segment
  1113.     .BA    begin single-spaced indented block
  1114.     .BZ    end single-spaced indented block
  1115. .fi
  1116. .ne 8
  1117. .sp 2
  1118. .ce
  1119. \fIro Output and Post-Processor Development\fR
  1120. .P
  1121. The five sequences to control the printer are 
  1122. sen, on output, as the ESCAPE character (0x1b hex, 
  1123. 27 decimal) followed by a single ASCII character.  
  1124. These sequences are:  
  1125. .sp
  1126. .nf
  1127.     ESCAPE    'R'    Set Roman Font
  1128.  
  1129.     ESCAPE     'I'    Set Italic Font
  1130.  
  1131.     ESCAPE  'B'    Set Bold Font
  1132.  
  1133.     ESCAPE    'u'    Up One-Half Line
  1134.  
  1135.     ESCAPE    'd'    Down One-Half Line
  1136. .fi
  1137. .sp
  1138. An ro postprocessor should intercept any 
  1139. ESCAPE character, then determine based 
  1140. on the next character following it what 
  1141. codes to send out.  
  1142. .P
  1143. As an example, the folowing is the entire 
  1144. text of the "termnx10" postprocessor.  
  1145. It should be relatively easy to alter 
  1146. the escape code sequences here to suit any 
  1147. printer.  
  1148. \fBPlease note\fR that in the version below 
  1149. we have had to doule each backslash character 
  1150. so that it would print correctly when output 
  1151. by ro.  If you want to cut this program 
  1152. out of ro.doc to compile it, you'll need 
  1153. to convert each double backslash to a single one.  
  1154. .sp
  1155. .nf
  1156.  
  1157. #include "stdio.h"
  1158. #include "term.h"
  1159.  
  1160. char progname[] = "termnx10";
  1161.  
  1162. main()
  1163.     {
  1164.     register int c;
  1165.  
  1166.     while( !feof( stdin ))
  1167.         {
  1168.         c = getchar();
  1169.         switch( c )
  1170.             {
  1171.             case ESCAPE:
  1172.                 getpc();
  1173.                 break;
  1174.             case EOF:
  1175.                 break;
  1176.             default:
  1177.                 putchar( c );
  1178.                 break;
  1179.             }
  1180.         }
  1181.     }
  1182.  
  1183. getpc()
  1184.     {
  1185.     register int c;
  1186.  
  1187.     c = getchar();
  1188.     switch( c )
  1189.         {
  1190.         case ROMAN:
  1191.             roman();
  1192.             break;
  1193.         case ITALIC:
  1194.             italic();
  1195.             break;
  1196.         case BOLD:
  1197.             bold();
  1198.             break;
  1199.         case HALFUP:
  1200.             halfup();
  1201.             break;
  1202.         case HALFDOWN:
  1203.             halfdown();
  1204.             break;
  1205.         default:
  1206.             fprintf( stderr, "%s:  unrecognized output escape sequence ESC-0x%x \n", progname, c );
  1207.             break;
  1208.         }
  1209.     }
  1210.  
  1211. roman()
  1212.     {
  1213.     printf( "\\0335\\033H" );
  1214.     }
  1215.  
  1216. italic()
  1217.     {
  1218.     printf( "\\0334" );
  1219.     }
  1220.  
  1221. bold()
  1222.     {
  1223.     printf( "\\033G" );
  1224.     }
  1225.  
  1226. halfup()
  1227.     {
  1228.     printf( "\\033j\\022" );
  1229.     }
  1230.  
  1231. halfdown()
  1232.     {
  1233.     printf( "\033J\022" );
  1234.     }
  1235.  
  1236. --------------------------------------------
  1237.  
  1238. Here's the included "term.h" file:
  1239.  
  1240. --------------------------------------------
  1241.  
  1242. #define    ESCAPE        0x1b
  1243.  
  1244. /**    Single-character printer code designations ***/
  1245.  
  1246. #define    ROMAN        'R'    /* Restore "roman" or "regular" font */
  1247.                 /* Should turn off Bold and Italic */
  1248. #define    ITALIC        'I'    /* Switch to italics or underline */
  1249. #define    BOLD        'B'    /* Switch to bold */
  1250. #define    HALFUP        'u'    /* Half-line up */
  1251. #define    HALFDOWN    'd'    /* Half-line down */
  1252.  
  1253. .fi
  1254.  
  1255.